<?php
    require_once('init.php');
    if(!Conf::isConnecter()) {
        Tools::redirect('index.php');
    }
    
    $autorisation = $_SESSION['client']->autorisation(Module::rechercheModule(1));
    if($autorisation->getDroit() == 0) {
        Tools::redirect('index.php');
    }
    
    require('header.php');
    
    $ventesPrivees = VentePrivee::getVentePrivees(false, true);    
    $ajd = new DateTime();
    
    echo    '<div class="title_vente_privee">
                <h3>VENTES PRIVEES</h3>
             </div>
            
            <div class="entete_vente_privee">
                ACTUELLEMENT
            </div>';
    echo '<div class="block_vente_privee">';
    foreach($ventesPrivees as $vp) {
        
        if ($ajd->format('Y-m-d H:i:s') > $vp->getDateDebut() && $vp->getDateFin() > $ajd->format('Y-m-d H:i:s')){
            echo    '<a href="details_vente_privee.php?id_vente_privee='.$vp->getId().'">
                        <img alt="#" src="img/vp/'.$vp->getId().'.jpg" title=""/>
                    </a>
                    <div class="libelle_vente_privee">          
                        Du '.Tools::getDayLetter($vp->getDateDebut('w')).'
                        <span class="mois_vente_privee">
                            '.$vp->getDateDebut('d').' '.Tools::getMonthLetter($vp->getDateDebut('m')).'
                        </span>
                        à 7h au '.Tools::getDayLetter($vp->getDateFin('w')).'
                        <span class="mois_vente_privee">
                            '.$vp->getDateFin('d').' '.Tools::getMonthLetter($vp->getDateFin('m')).'
                        </span>
                    </div>';
        }
    }
    echo '</div>';
    
    $ventes_privees = VentePrivee::getVentePrivees(false,true);
    echo    '<div class="entete_vente_privee">
                PROCHAINEMENT
            </div>';
    
    foreach($ventes_privees as $vp) {
        if ($ajd->format('Y-m-d H:i:s') < $vp->getDateDebut()) {
            echo    '<div class="block_vente_privee">
                        <a href="details_vente_privee.php?id_vente_privee='.$vp->getId().'">
                            <img alt="#" src="img/vp/'.$vp->getId().'.jpg" title=""/>
                        </a>
                        <div class="libelle_vente_privee">
                            Du '.Tools::getDayLetter($vp->getDateDebut('w')).'
                            <span class="mois_vente_privee">
                                '.$vp->getDateDebut('d').' '.Tools::getMonthLetter($vp->getDateDebut('m')).'
                            </span>
                            à 7h au '.Tools::getDayLetter($vp->getDateFin('w')).'
                            <span class="mois_vente_privee">
                                '.$vp->getDateFin('d').' '.Tools::getMonthLetter($vp->getDateFin('m')).'
                            </span>
                        </div>
                    </div>';
        }
    }
    
    require('footer.php');
?>



